﻿using System;
using Syngine.Components;

namespace Syngine.Controls.Navigation
{
	/// <summary>
	/// 
	/// </summary>
	public class MenuItem : Control
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the <see cref="MenuItem"/> class.
		/// </summary>
		/// <param name="menu">The menu.</param>
		public MenuItem(Menu menu)
		{
			Menu = menu;
			Click += i => OnMenuItemClicked();
			MenuItemClicked += menu.MenuItemClicked;
		}

		#endregion

		#region Properties

		/// <summary>
		/// Occurs when this menu item is clicked.
		/// </summary>
		protected event Action<MenuItem> MenuItemClicked;

		/// <summary>
		/// Gets the <see cref="Menu"/> who owns this <see cref="MenuItem"/>.
		/// </summary>
		/// <value>The <see cref="Menu"/> who owns this <see cref="MenuItem"/>.</value>
		public Menu Menu { get; private set; }

		/// <summary>
		/// Gets or sets the command.
		/// </summary>
		/// <value>The command.</value>
		public ICommand Command { get; set; }

		#endregion

		#region Methods

		/// <summary>
		/// Called when [menu item clicked].
		/// </summary>
		protected virtual void OnMenuItemClicked()
		{
			InvokeEvent(MenuItemClicked, this);
		}

		#endregion
	}
}